home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / codeli_1 / setup.exe / _SETUP.1 / CallFormatDialog.bas next >
Encoding:
BASIC Source File  |  1997-07-21  |  2.2 KB  |  79 lines

  1. Attribute VB_Name = "CallFormatDialog"
  2. Public Const WM_CLOSE = &H10
  3.  
  4. Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
  5.  
  6. Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  7. Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  8. Declare Function GetDesktopWindow Lib "user32" () As Long
  9. Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
  10. Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  11. Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  12.  
  13. Type RECT
  14.         Left As Long
  15.         Top As Long
  16.         Right As Long
  17.         Bottom As Long
  18. End Type
  19.  
  20. Type POINTAPI
  21.         X As Long
  22.         y As Long
  23. End Type
  24.  
  25. Const SWP_NOSIZE = &H1
  26. Const SWP_NOZORDER = &H4
  27. Public Sub FormatFloppy()
  28.  
  29. Dim sBuffer As String, Windir As String, Procs As String, X
  30. Dim lResult As Long
  31.  
  32. sBuffer = String$(255, 0)
  33. lResult = GetWindowsDirectory(sBuffer, Len(sBuffer))
  34.  
  35. Windir = Trim(sBuffer)
  36.  
  37. Procs = Left(Windir, lResult) & "\rundll32.exe shell32.dll,SHFormatDrive"
  38.  
  39.     Call CenterDialog("Format - 3╜ Floppy (A:)")
  40.     X = Shell(Procs, 1)
  41.     Call CenterDialog("Format - 3╜ Floppy (A:)")
  42.  
  43. k = LockWindowUpdate(0)
  44.  
  45. End Sub
  46. Public Sub CenterDialog(WinText As String)
  47.  
  48. DoEvents
  49.  
  50. On Error Resume Next
  51.  
  52. Dim D3 As Long
  53. D3 = LockWindowUpdate(GetDesktopWindow())
  54. Dim wdth%
  55. Dim hght%
  56. Dim Scrwdth%
  57. Dim Scrhght%
  58. Dim lpDlgRect As RECT
  59. Dim lpdskrect As RECT
  60.  
  61. Dim hTaskBar As Long
  62.  
  63. hTaskBar = FindWindow(0&, WinText)
  64.  
  65.     Call GetWindowRect(hTaskBar, lpDlgRect)
  66.     wdth% = lpDlgRect.Right - lpDlgRect.Left
  67.     hght% = lpDlgRect.Bottom - lpDlgRect.Top
  68.     Call GetWindowRect(GetDesktopWindow(), lpdskrect)
  69.     Scrwdth% = lpdskrect.Right - lpdskrect.Left
  70.     Scrhght% = lpdskrect.Bottom - lpdskrect.Top
  71.  
  72.     X% = (Scrwdth% - wdth%) / 2
  73.     y% = (Scrhght% - hght%) / 2
  74.     Call SetWindowPos(hTaskBar, 0, X%, y%, 0, 0, SWP_NOZORDER Or SWP_NOSIZE)
  75.  
  76. DoEvents
  77.  
  78. End Sub
  79.